package com.example.sup.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.sup.controller.request.PlanSettingRequest;
import com.example.sup.controller.response.ServerResponse;
import com.example.sup.service.PlanSettingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName PlanSettingController
 * @Description {TODO}
 * @Author 李哲
 * @Date 22:21 2024/7/23
 * @Version 1.0
 */
@RestController
@Slf4j
@RequestMapping("/plansetting")
public class PlanSettingController {

    @Resource
    private PlanSettingService planSettingService;

    @PostMapping("/query")
    public ServerResponse query(@RequestBody PlanSettingRequest planSettingRequest) {
        //1.参数校验
        //2.调用service
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.ne("reserved_fields1", planSettingRequest.getReservedFields1());

        //3.返回结果
        List list = planSettingService.list(queryWrapper);
        if (list.size() == 0){
            return ServerResponse.failWithMsg("操作失败");
        }
        return ServerResponse.successWithMsg("操作成功",list);
    }

}
